﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using Common;
using Common.Views;

namespace BusinessLogic
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the interface name "IUsersService" in both code and config file together.
    /// <summary>
    /// This interface contains methods found in the UsersService which send and get data regarding 
    /// users to and from the Users, Roles and UserRoles tables in the database.
    /// </summary>
    [ServiceContract]
    public interface IUsersService
    {
        /// <summary>
        /// A method which adds a new User in the Users table in the database
        /// </summary>
        /// <param name="username">The username of the new user</param>
        /// <param name="password">The password of the new user</param>
        /// <param name="pin">The PIN number of the new user</param>
        /// <param name="name">The name of the new user</param>
        /// <param name="surname">The surname of the new user</param>
        /// <param name="email">The email of the new user</param>
        /// <param name="mobileNo">The mobile number of the new user</param>
        /// <param name="residence">The residence of the new user</param>
        /// <param name="street">The street of residence of the new user</param>
        /// <param name="town">The town of residence of the new user</param>
        /// <param name="country">The country of residence of the new user</param>
        [OperationContract]
        void AddUser(string username, string password, int pin, string name, 
            string surname,string email, string mobileNo, string residence, string street, string town, string country);

        /// <summary>
        /// A method which is used to authenticate the user with the website according to the details in the database
        /// </summary>
        /// <param name="username">The username of the user which will be used to authenticate the user</param>
        /// <param name="token">The token which was previously generated upon registeration.
        /// This is used to authenticate the user.</param>
        /// <param name="pin">The PIN number of the user which will be used to authenticate the user</param>
        /// <returns>A boolean value which indicates whether authentication was successful or not</returns>
        [OperationContract]
        bool AuthenticateUser(string username, string token, int pin);

        /// <summary>
        /// Gets a username which has the specified username
        /// </summary>
        /// <param name="username">The username of the user, which will be used to get the User</param>
        /// <returns>A user which has the specified username</returns>
        [OperationContract]
        User GetUser(string username);

        /// <summary>
        /// A method which gets all the uesrnames of the registered users found in the database
        /// </summary>
        /// <returns>A list of all the usernames of the registered users</returns>
        [OperationContract]
        IEnumerable<UsersView> GetUsernames();

        /// <summary>
        /// A method which is used to check whether a username already exists in the database
        /// </summary>
        /// <param name="username">The username for which to check if the username exists</param>
        /// <returns>A boolean value which indicates whether the username exists or not</returns>
        [OperationContract]
        bool DoesUsernameExist(string username);

        /// <summary>
        /// A method which is used to check whether an email already exists in the database
        /// </summary>
        /// <param name="email">The email for which to check if the email exists</param>
        /// <returns>A boolean value which indicates whether the email address exists or not</returns>
        [OperationContract]
        bool DoesEmailExist(string email);

        /// <summary>
        /// A method which is used to check whether a PIN already exists in the database
        /// </summary>
        /// <param name="pin">The PIN for which to check if the PIN exists</param>
        /// <returns>A boolean value which indicates whether the PIN exists or not</returns>
        [OperationContract]
        bool DoesPinExist(int pin);
    }
}
